package com.lanou.managerLogin.book.service;

import com.lanou.managerLogin.book.dao.BookDao;
import com.lanou.managerLogin.book.dao.BookDaoImpl;
import com.lanou.managerLogin.book.domain.Book;

import java.util.ArrayList;
import java.util.List;

public class BookService {
    private BookDao bd = new BookDaoImpl();

    public List<Book> listBook() {
        List<Book> bookCategories = bd.bookList();
        if (bookCategories.size() == 0) {
            System.out.println("啥也没有");
        } else {
            return bookCategories;
        }
        return new ArrayList<>();
    }

    public Book oneBookLoad(String bid) {
        Book books = bd.oneBookInfo(bid);
        return books;
    }

    public String findCnameByCid(String cid) {
        String cnameByCid = bd.findCnameByCid(cid);
        if (cnameByCid == null) {
            System.out.println("啥也没有");
        } else {
            return cnameByCid;
        }
        return null;
    }

    public void deleteOneBook(String bid){
        bd.deleteOneBook(bid);
    }

    public void insertBook(Book book){
        bd.insertBook(book);
    }
}
